
import traceback, pygame

class SpriteHandler:

    spritePath = {}
    sprites = {}
    
    @staticmethod
    def register(name, path):
        SpriteHandler.spritePath[name] = path
        
    @staticmethod
    def load():
        print("load sprites")
        for name in SpriteHandler.spritePath:           
            try:            
               image = pygame.image.load(SpriteHandler.spritePath[name])
               SpriteHandler.sprites[name] = image.convert_alpha()
               print("Image " + name + " loaded successfully")
            except:
                print("can't load image " + name + " at " + SpriteHandler.spritePath[name])
                traceback.print_exc()
                
    @staticmethod      
    def get(name):
        return SpriteHandler.sprites[name]
